//
//  UIViewController+XHNHud.m
//  PockPower
//
//  Created by 邢行 on 2017/7/2.
//  Copyright © 2017年 XingHang. All rights reserved.
//

#import "UIViewController+XHNHud.h"
#import "XHNHudManager.h"
#import "MBProgressHUD.h"

@interface UIViewController ()


@end


@implementation UIViewController (XHNHud)


-(void)showWithText:(NSString *)msg{
    
//    [XHNHudManager showWithText:msg];
    [self showAlert:msg];
}


- (void)showActivity:(NSString *)content {
    
    [self hideAllAlert];
    MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
    hud.label.text = content;
//    hud.label.textColor = [UIColor whiteColor];
    hud.contentColor = [UIColor whiteColor];

}

- (void)hideAllAlert {
    [MBProgressHUD hideHUDForView:self.view animated:YES];
    
}

- (MBProgressHUD *)showAlert:(NSString *)content {
    
    [self hideAllAlert];
    MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
    hud.label.text = content;
    hud.mode = MBProgressHUDModeText;
    hud.contentColor = [UIColor whiteColor];
    //提示框背景颜色
//    hud.bezelView.backgroundColor = [UIColor yellowColor];
    //整个页面的背景色（全屏的）
//    hud.backgroundView.backgroundColor = [UIColor redColor];
    [hud hideAnimated:YES afterDelay:1];
    return hud;
}
    
- (MBProgressHUD *)showAlert:(NSString *)content completionBlock:(MBProgressHUDCompletionBlock)completionBlock {
    MBProgressHUD *hud = [self showAlert:content];
    hud.completionBlock = completionBlock;
    return hud;
}
    
- (MBProgressHUD *)showAlert:(NSString *)content afterDelay:(NSTimeInterval)afterDelay {
    
    MBProgressHUD *hud = [self showAlert:content];
    [hud hideAnimated:YES afterDelay:afterDelay];

    return hud;
}
    
- (MBProgressHUD *)showAlert:(NSString *)content afterDelay:(NSTimeInterval)afterDelay completionBlock:(MBProgressHUDCompletionBlock)completionBlock {
    
    MBProgressHUD *hud = [self showAlert:content afterDelay:afterDelay];
    hud.completionBlock = completionBlock;
    return hud;
}
    

@end
